function [OUTtext,Text_ty,text_MAE,text_rmse,BP_A1C1_R2]=BP_TSK_A1C1(Train_X,Train_D,Text_z,Text_ty,PS)

[N,~]=size(Train_X);[N1,~]=size(Text_z);
rule=5;sigma=0.6*ones(rule,7);
M = Train_X(1:rule,:); 
% M = Text_z(1:rule,:); 
C=0.5*rand(rule,8);
alpha=0.03;
S=0.06*rand(rule,8);
Nn=50;MT=M;sigmaT=sigma;CT=C;
for i=1:Nn    
% [M,C,S,sigma]=train_tsk_type1(Train_X,Train_D,M,sigma,C,S,alpha);
[M,C,S,sigma]=train_tsk_type1(Text_z,Text_ty,M,sigma,C,S,alpha);
[~,~,OUTtext]=tsk_type2(Text_z,M,sigma,C,S);
rmse(i)= sqrt((OUTtext-Text_ty)*(OUTtext-Text_ty)'/N1);
end
[~,n]=min(rmse);sigma=sigmaT;C=CT;M=MT;

for i=1:n
% [M,C,S,sigma]=train_tsk_type1(Train_X,Train_D,M,sigma,C,S,alpha);
[M,C,S,sigma]=train_tsk_type1(Text_z,Text_ty,M,sigma,C,S,alpha);
[~,~,OUTtrain]=tsk_type2(Train_X,M,sigma,C,S);
[~,~,OUTtext]=tsk_type2(Text_z,M,sigma,C,S);
end
out_data=[OUTtrain';OUTtext'];input_data=[Train_X;Text_z];
o_data=[input_data,out_data];oo_data=o_data';
[oo_data,PS]=mapminmax('reverse',oo_data,PS);
DATA=oo_data';
OUTtrain=DATA(1:N,end)';OUTtext=DATA(N+1:N+N1,end)';

output_data=[Train_D';Text_ty'];orin_data=[input_data,output_data];
[orin_data,PS]=mapminmax('reverse',orin_data',PS);
orin_out=orin_data';Train_D=orin_out(1:N,end)';Text_ty=orin_out(N+1:N+N1,end)';

TEXT_msemin= (OUTtext-Text_ty)*(OUTtext-Text_ty)'/N1;
text_MAE=(1/N1)*sum(abs(OUTtext-Text_ty));
text_rmse=sqrt(TEXT_msemin);
BP_A1C1_R2=1 - (sum((OUTtext- Text_ty).^2) / sum((OUTtext - mean(Text_ty)).^2));
end

